// 柱状图
<template>
  <el-scrollbar >
    <div class="barStatic" v-if="echartData.data.length > 0">
      <div class="bar-chart-left">
        <div class="bar-chart-left-main">
          <div class="bar-chart-left-txt" v-for="(item,index) in echartData.lableText" :key="index">{{item}}</div>
        </div>
      </div>
      <div class="bar-chart-right">
        <div class="bar-chart-right-main">
          <div class="bar-chart-right-content" v-for="(item,index) in echartData.data" :key="index"
               @click="clickBar(index)">
            <div class="bar-chart-right-line" v-if="Math.max(...echartData.data)>0" :style="`width:${(item/Math.max(...echartData.data))* 100}%`" ></div>
            <div class="bar-chart-right-line" v-else style="width:0"></div>
            <text class="bar-chart-right-line-txt">{{item}}</text>
          </div>
        </div>
        <!--虚线-->
        <div class="bar-chart-right-dash">
          <div class="bar-chart-right-dash-line"  v-for="i in 4" :key="i">
          </div>
        </div>
      </div>
    </div>
    <div class="barStatic chart-noData" v-else>
      <div>
        <img :src="noData" class="has-noData"/>
      </div>
      <div>暂无数据</div>
    </div>
  </el-scrollbar>

</template>

<script lang="js">
import noData from '@/assets/noData.png'
export default {
  name: 'barStatic',
  components: {},
  props:{
    barCanvas:{
      type:String,
      default:''
    },
    echartData:{
      type:Object,
      default:()=>{

      }
    }
  },
  data(){
    return{
      noData:noData
    }
  },
  mounted () {
  },
  methods: {
    clickBar(index) {
      console.log('pctapcb index=', index)
      this.$emit('clickChartCallBack', index)
    }
  }
}
</script>

<style>
.barStatic {
  width: 100%;
  display: flex;
  align-items: baseline;
  min-height: 180px;
  padding: 24px 0;
}
.barStatic .bar-chart-left{
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: right;
  color: #333333;
  padding-right: 14px;
  min-height: 180px;
}
.barStatic .bar-chart-left-main{
  display: grid;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  min-height: 180px;
}
.barStatic .bar-chart-left-txt{
  width: 100%;
  white-space: nowrap;
  line-height: 18px;
}
.barStatic .bar-chart-left .bar-chart-left-txt,.barStatic .bar-chart-right .bar-chart-right-content{
  margin-bottom: 12px;
}
.barStatic .bar-chart-left .bar-chart-left-txt:last-child,.barStatic .bar-chart-right .bar-chart-right-content:last-child{
  margin-bottom: 0;
}
.barStatic .bar-chart-right-content{
 display: flex;
  align-items: center;
  justify-items: center;
  width: 100%;
}
.barStatic .bar-chart-right-line{
  width: 69%;
  height: 10px;
  background: #C09F88;
  border-radius: 2px;
}
.barStatic .bar-chart-right-line-txt{
  /* width: 16px; */
  height: 18px;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  color: #C09F88;
  line-height: 18px;
  margin-left: 16px;
}
.barStatic .bar-chart-right{
  border-left: 1px solid #cfd1d3;
  flex-grow: 1;
  position: relative;
  min-height: 180px;
}
.barStatic .bar-chart-right-dash-line{
  height: 100%;
  width: 20%;
  border-right:1px dashed #f2f2f2;
}
.barStatic .bar-chart-right-main{
  display: flex;
  z-index: 1;
  flex-wrap: wrap;
  min-height: 180px;
  position: relative;
}
.barStatic .bar-chart-right-dash{
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  display: flex;
  z-index: 0;
}
.chart-noData{
  display: flex;
  align-items: center;
  justify-items: center;
  flex-wrap: wrap;
  align-content:center;
  color: #999999;
}
.chart-noData div{
  width: 100%;
  text-align: center;
}
.chart-noData img{
  width: 80px;
}
</style>
